package SwingView.Announcement;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import JDBC.InstructorAnnouncementActivities;
import SwingController.CmsPresenter;
import SwingModel.CmsAnnouncement;
import SwingModel.CmsUser;
import SwingView.CmsMainView;

public class ALAnnouncementDelete implements ActionListener{

	private CmsAnnouncement anm;
	
	public ALAnnouncementDelete(CmsAnnouncement anm){
		this.anm = anm;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		CmsUser user = CmsPresenter.user;
		CmsMainView mainView = CmsPresenter.mainView;
		
		InstructorAnnouncementActivities.deleteAnnouncement(user.getUsername(), anm.getAnnouncementID());
		
		mainView.displayAnnouncementInstructorPage(InstructorAnnouncementActivities.getListOfAnnouncement(user.getUsername() 
																						,user.getSelectedCourse().getCourseID()));
	}

}
